<?php

class Core_Model_Website_Collection_Menu extends Dcmp_Model_Collection_Strong {

    public function __construct() {
        parent::__construct();
        $this->setItemClass('website/menu');
        $this->from('{t}website_menu', 'a')->select()->field('a.*');
    }

    

    public function joinAccount() {
        $this->join()->inner('{t}permission_account', 'b')->on('a.creator_id', 'b.id')
                ->closest()
                ->select()->field('b.full_name', 'creator_name');
        return $this;
    }

    public function filterBy($name, $arg) {
        switch ($name) {
            case 'area':
                $this->addParameter('areaId', $arg)->where()->eq('area_id', ':areaId:i');
                break;
        }
        return parent::filterBy($name, $arg);
    }

}

